<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="|#{customer.systemTitle}-图灵谷-全局配置-全局配置|">图灵谷</title>
<div th:replace="fragments/head_admin">head</div>
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		<div th:replace="fragments/nav_admin">导航栏</div>
		<div th:replace="fragments/menu_admin::menu(parent=gconfig,child=model)">菜单栏</div>
		<div class="layui-body">
			<div class="layui-main">
				<!--/***** 面包屑 *****/-->
				<div class="layui-elem-quote" style="margin-top: 10px;">
					<span class="layui-breadcrumb"> <a><cite>全局配置</cite></a> <a th:href="@{/admin/m/base/model/list.gsp}">字段配置</a> <a><cite>新增</cite></a>
					</span>
				</div>
				<blockquote class="layui-elem-quote layui-quote-nm" style="color: #FF5722">
					<i class="layui-icon">&#xe60b;</i> 字段配置
				</blockquote>
				<form th:action="@{/admin/m/base/customField/add.gsp}" id="addForm" role="form" class="layui-form" action="#" method="post">
					<fieldset class="layui-elem-field layui-field-title">
						<legend>新增字段</legend>
					</fieldset>
					<input name="ownerType" type="text" th:value="|${model.Type}Model|" hidden="true" /> <input name="ownerId" type="text" th:value="${model.Id}" hidden="true" /> <input name="innerType" type="text" value="1" hidden="true" /> <input name="newline" type="text" value="1" hidden="true" /> <input
						name="state" type="text" value="1" hidden="true" />
					<div class="layui-form-item">
						<label class="layui-form-label">字段类型：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<select name="type" id="type" lay-filter="type">
								<option selected="selected" value="1">文本输入框</option>
								<option value="2">日期输入框</option>
								<option value="3">单选框</option>
								<option value="4">多选框</option>
								<option value="5">文本域</option>
								<option value="6">文本编辑器</option>
								<option value="7">图片上传</option>
								<option value="8">图片集上传</option>
								<option value="9">视频上传</option>
								<option value="10">附件上传</option>
								<option value="11">文库上传</option>
								<option disabled="disabled" value="12">属性控件</option>
							</select>
						</div>
					</div>
					<div class="layui-form-item" id="dateFormatDiv" style="display: none">
						<label class="layui-form-label">日期格式化：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<select name="dateFormat">
								<option selected="selected" value="yyyy-MM-dd">yyyy-MM-dd</option>
								<option value="HH:mm:ss">HH:mm:ss</option>
								<option value="yyyy-MM-dd HH:mm:ss">yyyy-MM-dd HH:mm:ss</option>
							</select>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">字段标签：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<input name="fieldLabel" placeholder="请输入字段标签" required lay-verify="fieldLabel" type="text" class="layui-input" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">字段名称：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<input name="fieldName" placeholder="请输入字段名称" required lay-verify="fieldName" type="text" class="layui-input" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">是否必填：<span style="color: red">*</span></label>
						<div class="layui-input-block">
							<input type="radio" checked="checked" value="1" title="是" name="required" id="inlineRadio1" /> <input type="radio" value="2" title="否" name="required" id="inlineRadio2" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">默认值：</label>
						<div class="layui-input-block">
							<input name="fieldDefaultValue" placeholder="请输入默认值" lay-verify="fieldDefaultValue" type="text" class="layui-input" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">最大长度：</label>
						<div class="layui-input-block">
							<input name="fieldMaxLength" placeholder="请输入最大长度" lay-verify="fieldMaxLength" type="text" class="layui-input" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">提示信息：</label>
						<div class="layui-input-block">
							<input name="prompt" placeholder="请输入提示信息" type="text" lay-verify="prompt" class="layui-input" />
						</div>
					</div>
					<div class="layui-form-item" id="checkboxOptionsDiv" style="display: none">
						<label class="layui-form-label">可选项：</label>
						<div class="layui-input-block">
							<textarea name="checkboxOptions" lay-verify="checkboxOptions" placeholder="请输入可选项" class="layui-textarea" type="text" maxlength="150"></textarea>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit="" lay-filter="submit1">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div th:replace="fragments/footer_admin">底部</div>
	</div>
</body>
<div th:replace="fragments/import_js_admin">引入js</div>
</html>
<script th:inline="javascript">
    /*<![CDATA[*/
    var form = layui.form();
    //自定义验证规则
    form.verify({
        fieldLabel : function(value) {
            if (value.length < 1) {
                return '标签不能为空！';
            } else if (value.length > 20) {
                return '标签长度不能大于20个字符!';
            }
        },
        fieldName : function(value) {
            if (value.length < 1) {
                return '字段名称不能为空！';
            } else if (value.length > 20) {
                return '字段名称不能大于20个字符!';
            }
        },
        fieldDefaultValue : function(value) {
            if (value.length > 20) {
                return '默认值不能大于20个字符!';
            }
        },
        prompt : function(value) {
            if (value.length > 20) {
                return '提示信息不能大于20个字符!';
            }
        },
        checkboxOptions : function(value) {
            if (value.length > 200) {
                return '描述不能太长哦，最长200个字！';
            }
        }
    });
    //监听提交
    form.on('submit(submit1)', function(data) {
    });
    //监听SELECT
    form.on('select(type)', function(data) {
        if (data.value == 2) {
            $('#dateFormatDiv').show();
        } else {
            $('#dateFormatDiv').hide();
        }
        if (data.value == 3 || data.value == 4) {
            $('#checkboxOptionsDiv').show();
        } else {
            $('#checkboxOptionsDiv').hide();
        }
    });
    /*]]>*/
</script>